package com.redsoft.epip.dao;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.redsoft.epip.entity.Member;
import com.redsoft.spirit.dao.BaseRepository;

/**
 * 会员管理的DAO
 * 
 * <pre>
 * 会员管理的DAO
 * </pre>
 * 
 * @author 
 * @since 1.0
 */
public interface MemberRepository extends BaseRepository<Member, String>{

	Member findByOpenId(String openId);
	
	/**
	 * 根据ID删除
	 * 
	 * @param id
	 */
	@Modifying
	@Query("update Member set isDeleted=1 where id = ?1")
	void deleteById(String id);
	
	@Query("from Member m where m.phoneNo = ?1 and m.isDeleted = 0")
	Member findByPhoneNo(String phoneNo);
	
	@Query("from Member m where m.id = ?1 and m.isDeleted = 0")
	Member getMemberById(String id);

}
